# 定义BankAccount类
class BankAccount:
    def __init__(self, initial_balance=0):
        self.balance = initial_balance

    # 实现存钱操作
    def deposit(self, amount):
        if amount > 0:
            self.balance += amount
            print(f"已存入 {amount} 元\n余额为 {self.balance} 元")
        else:
            print("存款金额必须大于0元。")

    # 实现取钱操作
    def withdraw(self, amount):
        if amount > 0:
            if amount <= self.balance:
                self.balance -= amount
                print(f"已取出 {amount} 元\n余额为 {self.balance} 元")
            else:
                print("取款失败，余额不足！")
        else:
            print("取款金额必须大于0元！")


# 调用类，进行存取操作，并输出结果
account = BankAccount(int(input('请输入账户初始值：')))
account.deposit(int(input('请输入存款金额：')))
account.withdraw(int(input('请输入取款金额:')))
account.withdraw(int(input('请输入取款金额:')))
